package ar.edu.unlp.info.tesis.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 * Informaci�n del contexto para un statement
 * 
 * Espec: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#context
 *
 */

@Entity
@Table(name = "Context")
public class Context {
	
	private long id;
	
	private Actor instructor;
	
	private Group team;
		
//	private List<Statement> contextActivities;
	
	private String revision;
	
	private String plataform;
	
	private StatementRef statement;
	
	private List<Statement> extensions;

	@Id
	@GeneratedValue
	@Column(name = "ID")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "INSTRUCTOR", nullable = true)
	public Actor getInstructor() {
		return instructor;
	}

	public void setInstructor(Actor instructor) {
		this.instructor = instructor;
	}

	@ManyToOne()
	@JoinColumn(name = "TEAM", nullable = true)
	public Group getTeam() {
		return team;
	}

	public void setTeam(Group team) {
		this.team = team;
	}

//	@ManyToMany
//	@JoinTable(name = "CONTEXT_STATEMENT", joinColumns = @JoinColumn(name = "CONTEXT_ID"), inverseJoinColumns = @JoinColumn(name = "ACTIVITY_ID"))
//	@LazyCollection(LazyCollectionOption.TRUE)
//	public List<Statement> getContextActivities() {
//		return contextActivities;
//	}
//
//	public void setContextActivities(List<Statement> contextActivities) {
//		this.contextActivities = contextActivities;
//	}

	@Column(name = "REVISION")
	public String getRevision() {
		return revision;
	}

	public void setRevision(String revision) {
		this.revision = revision;
	}

	@Column(name = "PLATAFORM")
	public String getPlataform() {
		return plataform;
	}

	public void setPlataform(String plataform) {
		this.plataform = plataform;
	}

	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "STATEMENT", nullable = true)
	public StatementRef getStatement() {
		return statement;
	}

	public void setStatement(StatementRef statement) {
		this.statement = statement;
	}

	@ManyToMany
	@JoinTable(name = "CONTEXT_STATEMENT", joinColumns = @JoinColumn(name = "CONTEXT_ID"), inverseJoinColumns = @JoinColumn(name = "STATEMENT_ID"))
	@LazyCollection(LazyCollectionOption.TRUE)
	public List<Statement> getExtensions() {
		return extensions;
	}

	public void setExtensions(List<Statement> extensions) {
		this.extensions = extensions;
	}


}
